package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	/**
	 * ...
	 * @author Lorenzo Nuvoletta
	 */
	public class Main extends Sprite 
	{
		private var sprite1:Sprite;
		private var sprite2:Sprite;
		private var tf1:TextField;
		private var tf2:TextField;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			sprite1 = new Sprite();
			addChild(sprite1);
			sprite2 = new Sprite();
			sprite1.addChild(sprite2);
			
			sprite1.graphics.beginFill(0x444444);
			sprite1.graphics.drawRect(0, 0, 200, 200);
			sprite1.graphics.endFill();
			
			sprite2.graphics.beginFill(0xCCAAAA);
			sprite2.graphics.drawRect(0, 0, 100, 100);
			sprite2.graphics.endFill();
			
			sprite1.x = sprite1.y = 200;
			sprite2.x = sprite2.y = 50;
			
			tf1 = new TextField();
			tf1.width = 500;
			addChild(tf1);
			tf1.y = 500;
			tf1.text = "Gray";
			
			tf2 = new TextField();
			tf2.width = 500;
			addChild(tf2);
			tf2.y = 550;
			tf2.text = "Pink";
			
			
			sprite1.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
			sprite1.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
			sprite2.addEventListener(MouseEvent.ROLL_OVER, rollOver);
			sprite2.addEventListener(MouseEvent.ROLL_OUT, rollOut);
		}	
		
		private function mouseOver(e:MouseEvent):void 
		{
			tf1.text = "Gray: MouseOver";
		}
		
		private function mouseOut(e:MouseEvent):void 
		{
			tf1.text = "Gray: MouseOut";
		}
		
		
		private function rollOver(e:MouseEvent):void 
		{
			tf2.text = "Pink: RollOver";
		}
		
		private function rollOut(e:MouseEvent):void 
		{
			tf2.text = "Pink: RollOut";
		}
		
		
		
	}
	
}